package com.onesports.intelligent.k12.polarlight.controller.operation;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.onesports.intelligent.k12.polarlight.common.utils.ResultUtil;
import com.onesports.intelligent.k12.polarlight.constant.ApiPathConstants;
import com.onesports.intelligent.k12.polarlight.domain.dto.market.ProductSelectDTO;
import com.onesports.intelligent.k12.polarlight.domain.dto.operation.OperationProductCourseDTO;
import com.onesports.intelligent.k12.polarlight.domain.vo.course.CourseIdAndCourseNamelVO;
import com.onesports.intelligent.k12.polarlight.domain.vo.course.CourseScheduleDetailVO;
import com.onesports.intelligent.k12.polarlight.domain.vo.product.ProductSelectByIdVO;
import com.onesports.intelligent.k12.polarlight.domain.vo.product.ProductSelectPageVO;
import com.onesports.intelligent.k12.polarlight.service.sys.ProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @author chenrl
 * @since 2022-7-8
 */
@Api(value = "运营", tags = "运营端-商品管理")
@RestController
@RequestMapping(ApiPathConstants.OPERATION_PRODUCT)
@RequiredArgsConstructor
public class ProductOperationController {

    @Resource
    private final ProductService service;

    @ApiOperation("条件查询带分页")
    @GetMapping("/select-page")
    public ResponseEntity<IPage<ProductSelectPageVO>> selectPage(ProductSelectDTO productSelectByOperateDTO) {
        return ResultUtil.success(service.selectPage(productSelectByOperateDTO));
    }

    @ApiOperation("根据id查看商品详情")
    @GetMapping("/select-by-id")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "productId", value = "商品id", required = true, dataType = "long", paramType = "query"),
    })
    public ResponseEntity<ProductSelectByIdVO> selectById(String productId) {
        return ResultUtil.success(service.selectById(productId));
    }


    @ApiOperation(value = "查看排课表")
    @GetMapping("/get-course")
    public ResponseEntity<List<CourseScheduleDetailVO>> getCourse(@Valid OperationProductCourseDTO dto) {
        return ResultUtil.success(service.getProductCourse(dto));
    }
    @ApiOperation(value = "查看课表id与名称")
    @GetMapping("/get-course-id")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "courseId", value = "课程id", required = true, dataType = "long", paramType = "query"),
    })
    public ResponseEntity<List<CourseIdAndCourseNamelVO>> getCourseId(String courseId) {
        return ResultUtil.success(service.getCourseId(courseId));
    }
}